﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace QLNSClient
{
    public partial class Frm_SAPTANGTN : DevExpress.XtraEditors.XtraForm
    {
        QLNSServiceReference.QLNSServiceClient sv = new QLNSServiceReference.QLNSServiceClient();
        
        public Frm_SAPTANGTN()
        {
            InitializeComponent();
        }

        public void LoadData()
        {
            gv_dsSAPTANGTN.DataSource = sv.getSapTangTN();
            gridView1.Columns[0].Caption = "Mã cán bộ";
            gridView1.Columns[1].Caption = "Họ tên";
            gridView1.Columns[2].Caption = "Giá trị thâm niên hiện tại";
            gridView1.Columns[3].Caption = "Ngày thâm niên gốc";

            int t = DateTime.Today.Month;
            labelControl2.Text = t.ToString();

            if (gridView1.DataRowCount > 0)
            {
                
                
            }
            else
            {
                MessageBox.Show("Chưa có dữ liệu!");
            }
        }

        private void Frm_SAPTANGTN_Load(object sender, EventArgs e)
        {
            LoadData();
        }


        public static string ValueRow;
        public static bool isSapTangTN = false;
        private void gridView1_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e)
        {
            try
            {
                e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("Ra quyết định thâm niên", QDThamNien));
                ValueRow = gridView1.GetFocusedRowCellValue(gridView1.Columns[0]).ToString();
                isSapTangTN = true;
                Frm_dsCoThamNien.isViewCoThamNien = false;
            }
            catch
            {
                MessageBox.Show("Bạn cần click vào dòng dữ liệu!", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void QDThamNien(object sender, EventArgs e)
        {
            splashScreenManager1.ShowWaitForm();
            Frm_CBPCTN frm = new Frm_CBPCTN();
            frm.capnhat = new Frm_CBPCTN.CapNhatDL(LoadData);
            frm.Show();
            splashScreenManager1.CloseWaitForm();
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            //LoadData();
        }
    }
}